/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.fatec.ads.facade;

import br.edu.fatec.ads.bo.BusinessObjectAcesso;
import br.edu.fatec.ads.classes.Acesso;
import org.hibernate.HibernateException;

/**
 *
 * @author Ubirajara
 */
public class FacadeAcesso {

    private static FacadeAcesso singleton = null;
    private BusinessObjectAcesso regraNegocio = null;

    private FacadeAcesso() {
        regraNegocio = new BusinessObjectAcesso();
    }

    public static FacadeAcesso getInstance(){
        if(singleton == null){
            singleton = new FacadeAcesso();
        }

        return singleton;
    }

    public void inserirTentativaAcesso(Acesso acesso){

        regraNegocio.beginTransaction();

        try{
            regraNegocio.inserir(acesso);

            regraNegocio.commitTransaction();
        }catch(HibernateException cause){
            regraNegocio.rollbackTransaction();

            cause.printStackTrace();
        }

    }

}
